package com.xbx.eduservice.controller;


import com.xbx.commonutils.R;
import com.xbx.eduservice.entity.EduSubject;
import com.xbx.eduservice.entity.subject.OneSubject;
import com.xbx.eduservice.service.EduSubjectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * <p>
 * 课程科目 前端控制器
 * </p>
 *
 * @author testjava
 * @since 2020-12-22
 */

@RestController
@RequestMapping("/eduservice/subject")
@CrossOrigin
public class EduSubjectController {
    @Autowired
    private EduSubjectService eduSubjectService;
    //添加课程分类
    @PostMapping("addSubject")
    public R addSubject(MultipartFile file){
        //得到上传的excel文件
        eduSubjectService.saveSubject(file,eduSubjectService);
        return R.ok();
    }

    //课程分类列表显示（树形结构）
    @GetMapping("getAll")
    public R getAllSubject(){
    List<OneSubject> list=eduSubjectService.getOneTwoSubject();
    return R.ok().data("result",list);
    }

}

